﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Chapter02
{
    //第二章
    class Program
    {
        //使用泛型
        static List<string> GetNames()
        {
            List<string> names = new List<string>();
            names.Add("哈哈");
            names.Add("伽伽");
            names.Add("哈哈");
            return names;
        }
        static List<Ts> CopyAtMost<Ts>(List<Ts> inputList,int count)
        {
            Type t = typeof(Ts);//获取泛型类型
            Console.WriteLine(t.Name);
            Console.WriteLine(t);
            List<Ts> resList = new List<Ts>();
            int count_rel = Math.Min(count, inputList.Count);
            for (int i = 0; i < count_rel; i++)
            {
                resList.Add(inputList[i]);
            }
            return resList;
        }
        static void CopyTest()
        {
            List<string> oldList = new List<string>();
            oldList.Add("字符串1");
            oldList.Add("字符串2");
            oldList.Add("字符串3");
            List<string> newList = CopyAtMost<string>(oldList,4);
            foreach (string vat in newList)
            {
                Console.WriteLine(vat);
            }
        }

        /// <summary>
        /// 延迟执行
        /// </summary>
        static void LamBaStu()
        {

        }

        static void Main(string[] args)
        {
            //CopyTest();
            //int i = 9;
            //double dd = 0.2;
            //Type t = typeof(double);
            //Type t1 = dd.GetType();
            //Console.WriteLine(t1);
        }
    }
}
